from odoo.addons.pay_connector.functions import pay_context
from odoo.addons.pay_connector.functions.service.impl import stripe_strategy


class RpPayInterface(object):

    def __init__(self, env):
        self.env = env

    def action_to_pay(self, strategy, pay_price, params, success_basic_path, error_basic_path):
        """
        Description:  支付逻辑
        Params:
        -strategy:策略
        -pay_price:支付金额
        -params:携带参数
        -success_basic_path:成功回调的路径URI
        -error_basic_path:失败回调的路径URI
        """
        success_url = (success_basic_path + params).strip()
        error_url = error_basic_path + params
        url = pay_context.PayContext(eval(f"stripe_strategy.{strategy}Strategy('{success_url}', '{error_url}', {pay_price})")).execute_pay_out()
        return url
